<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="cn.edu.nju.ws.sview.Config,cn.edu.nju.ws.sview.views.Group,cn.edu.nju.ws.sview.util.URIUtil,java.net.URLEncoder,java.util.Enumeration,cn.edu.nju.ws.sview.views.Entity,cn.edu.nju.ws.sview.views.View" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SView翻译</title>
<link rel="icon" href="/sview/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/sview/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/smoothness/jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/easyui.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/views/translate.css" />
<script type="text/javascript" src="/sview/script/jquery.js"></script>
<script type="text/javascript" src="/sview/script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/sview/script/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="/sview/script/global.js"></script>
<script type="text/javascript" src="/sview/script/views/translate.js"></script>
</head>
<body>
<%
	String lang = request.getParameter("lang");
if(lang!=null &&lang.equals("en")){
	request.getRequestDispatcher("translate.jsp").forward(request,response);
	return;
}else if(lang==null){
	lang="zh" ;
}

String genre = request.getParameter("genre");
String eidStr =  request.getParameter("eid");
String gnameString =(String)session.getAttribute("groupName");

int eid =0;
int etype=0;
if(genre==null||gnameString==null){
	String location = "../views/index.jsp";
	if(lang.equals("zh"))
		location = location+"?lang="+lang;
	response.sendRedirect(location);
	return;
}else{
	eid = Integer.parseInt(eidStr);
}
if(genre.equals(Entity.URI_ENTITY_Str))
	etype = Entity.URI_ENTITY;
else if(genre.equals(Entity.CUSTOM_ENTITY_Str))
		etype = Entity.CUSTOM_ENTITY;
else if(genre.equals(Entity.COLLECTION_Str))
	etype = Entity.COLLECTION;

int gid =Group.getGroupIdByName(gnameString);

/*view id >0 means enter from edit point*/
String vidStr = request.getParameter("vid");
int vid = 0;
if(vidStr!=null){
	vid = Integer.parseInt(vidStr) ;
}
if(vid<=0 || !View.isThere(vid)){
	String location = "../views/index.jsp";
	if(lang.equals("zh"))
		location = location+"?lang="+lang;
	response.sendRedirect(location);
	return;
}

View view = View.getViewByViewId(vid) ;
String srcLang= view.getLanguage();
int translatedViewID = View.getTranlatedView(vid);
if(translatedViewID>0){
	if(!View.isThere(translatedViewID)){
		String location = "../views/index.jsp";
		if(lang.equals("zh"))
	location = location+"?lang="+lang;
		response.sendRedirect(location);
		return;
	}
}
%>
<jsp:include page="/vheader_zh.jsp" flush="true">
   <jsp:param name="f" value="e"/>
</jsp:include>
<div class="container">
   <div class="top">
     <div class="mspacing"></div>
     <div class="operation">翻译</div>
     <div class="mspacing"></div>
   </div>
   <div class="mspacingLittle"></div>
   <div class="main">
   	   <div class="mspacing"></div>
		<div class="langBox"> 
			<div class="sld">
				<span class="src-lang">源语言:</span>
				<%
					String langStr = null;
					if(srcLang.equals("en")){
						langStr = "英语";
					}else if(srcLang.equals("zh")){
						langStr="中文（简体）";
					}
				%>
				<span class="srcLang"><%=langStr %></span>
			</div>
			<div class="old">
			   <span class="obj-lang">目标语言:</span>
			   <span class="objLang">
			      <select id="objLang">
			       <%
			       	if(srcLang.equals("en")) {
			       %>
			        <option value="zh">中文（简体）</option>
			       <%	
			       	}else if(srcLang.equals("zh")){
			       %>
			       	 <option value="en">英语</option>
			       <% 
			       	}
			       %>
			      </select>
			   </span>
			</div>
		</div>
		<div class="mspacing"></div>
		<div class="mspacingLittle"></div>
	   <div class="mspacing"></div>
		<div class="nameBox">
			<span class="mtitle">名称</span>&nbsp;
			<%if(translatedViewID>0){
				String tranlatedName = View.getViewByViewId(translatedViewID).getName();
			%>
				<input type="text" id="viewName" value="<%=tranlatedName%>" class="ftext"/>
			<%}else{ %>
				<input type="text" id="viewName" class="ftext"/>
			<%} %>
			<%
			   String viewName = view.getName();
			%>
			<span class="originTitle"><%=viewName %></span>
		</div>
		<div class="mspacing"></div>
		<div class="mspacingLittle"></div>
	<div class="mspacing"></div>
	<div class="vcontent" >
	 <ul class="dmList" ></ul>
	</div>	
	<div class="mspacing"></div>
	<div class="outdated ot"><a href="javascript:void(0)" class="showoutdate">上次翻译版本中的过时查询项</a><ul class="rmList" ></ul></div>
	 <div class="mspacing ot"></div>
	 <div class="mspacingLittle"></div>
	 <div class="edit-save"> 
     <input type="button" value="保存" class="sbutton btn btn-primary fb">
     <input type="button" value="取消" class="cbutton btn fb">
     </div>	
	</div>
</div>
<input type='hidden' name="display-lang" id="display-lang" value="zh"/>
<input type='hidden' id="etype" value=<%=etype %> />
<input type='hidden' id="genre" value=<%=genre %> />
<input type='hidden'  id="eid" value=<%=eid %> />
<input type='hidden'  id="vid" value=<%=vid%> />
<input type='hidden'  id="gid" value=<%=gid%> />
<input type='hidden'  id="tvid" value="<%=translatedViewID %>" />
<div class='hidden'>
	<div class="warning">
	   <div class="warnBox">
	    <p>你的编辑组已经翻译了当前视图</p> 
	    <p>点击<a class="translink">这里</a>去编辑那个翻译视图。 </p>
	   </div>
	</div>
</div>
<jsp:include page="/vfooter_zh.jsp"></jsp:include>
</body>
</html>